package pages {
	import flash.events.MouseEvent;
	import flash.text.TextFieldAutoSize;
	import flash.display.Sprite;
	import flash.text.TextField;
	/**
	 * @author martindyrby
	 */
	public class StartupPage extends AbstractPage {
		private var textfield : TextField;
		
		public function init():void {
			trace("yeah");
			textfield = new TextField();
			textfield.text = "Hello";
			textfield.embedFonts = false;
			addChild(textfield);
			
			var spr:Sprite = new Sprite();
			spr.graphics.beginFill(0x909090);
			spr.graphics.drawCircle(100, 100, 20);
			spr.graphics.endFill();
			spr.addEventListener(MouseEvent.CLICK, clickHandler);
			addChild(spr);
		}

		private function clickHandler(event : MouseEvent) : void {
			Sprite(event.target).removeEventListener(MouseEvent.CLICK, clickHandler);
			gotoNextPage();
		}
		
		public function gotoNextPage() : void {
			dispatchEvent(new NavigationEvent(NavigationEvent.NEXT));
		}
		
		public function moveBall(x:int):void {
			getChildAt(1).x = x;
		}
		
		public function setText(text:String):void {
			TextField(getChildAt(0)).text = text;
		}
		
		public function hideText(value:Boolean):void {
			getChildAt(0).visible = !value;
		}
	}
}
